<template>
  <div class="body">

    <div class="inputForm">
      <h3>请输入密码：</h3>
      <!-- 密码输入框 -->
      <van-password-input
              :value="value"
              info="密码为 6 位数字"
              :error-info="errorInfo"
              :focused="showKeyboard"
              :gutter="10"
              @focus="showKeyboard = true"
      />
      <!-- 数字键盘 -->
      <van-number-keyboard
              :show="showKeyboard"
              @input="onInput"
              random-key-order
              @delete="onDelete"
              @blur="showKeyboard = false"
      />
      <div style="text-align: center;margin-top: 2rem">
        <van-button round @click="auditLogin" class="btn_grey">验证</van-button>
      </div>
    </div>

  </div>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      value: '',
      errorInfo: '',
      showKeyboard: true
    };
  },
  methods: {
    onInput(key) {
      this.errorInfo='';
      this.value = (this.value + key).slice(0, 6);

    },
    onDelete() {
      this.errorInfo='';
      this.value = this.value.slice(0, this.value.length - 1);
    },
    auditLogin(){
      if(res==='0'){
        this.errorInfo='验证码错误';
      }else if(res==='1'){
        this.$router.push('/devicemes');
      }else{
        this.errorInfo='验证失败';
      }

    }
  },
};
</script>

<style scoped>
.body {
  height: 100%;
  width: 100%;
  /*background-image:url('../../public/img/home/background.png');*/
  -webkit-background-size: 100% 100%;
  background-size: 100% 100%;
  display: flex;
  flex-direction: column;
}
.inputForm {
  top: 40%;
  width: 100%;
  padding: 0 4rem;
  position: absolute;
}
.inputForm h3{
  padding: 0 15px;
  color: #666666;
}
/deep/ .van-password-input__security li{
  background-color: #d7d9de;
}

.btn_grey{
  height: 40px;
  padding: 5px 40px;
  font-size: 18px;
  background-color: #153744;
  color: #ffffff;
  border: #153744 1px solid;
}
</style>
